// See the Electron documentation for details on how to use preload scripts:
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
const { contextBridge } = require('electron')
// const { readFile } = require('original-fs')
///引入ipcRenderer，才能和渲染进程通信
const { ipcRenderer } = require('electron')
contextBridge.exposeInMainWorld('myAPI_1', {
    chrome_version: process.versions.chrome,
    electron_version: process.versions.electron,
    node_version: process.versions.node,
    ///向主进程保存文件
    saveFile: (data) => {
        ///第一个参数，信道标识，第二个参数，数据
        ipcRenderer.send('file_save', data)
        console.log(data)
    },
    readFile() {
        return ipcRenderer.invoke('file_read')
    }
})